#include <sys/types.h>
#include <fcntl.h>
#include "../ourhdr.h"

int main(int argc, char *argv[])
{
    if(argc !=2)
    {
        err_quit("usage: access.cmd <pathname>");
    }
    char *pathname = argv[1];
    if(access(pathname, R_OK) <0)
    {
        err_ret("access error for %s", pathname);
    }
    else
    {
        printf("read access OK\n");
    }

    if(open(pathname, O_RDONLY)<0)
    {
        err_ret("open error for %s", pathname);
    }
    else
    {
        printf("open for reading OK\n");
    }
    exit(0);
}